<html lang="zh" xmlns:th="http://www.thymeleaf.org">
	<head>
		<link rel="stylesheet" href="https://www.layuicdn.com/layui-v2.5.6/css/layui.css">
		<script src="https://www.layuicdn.com/layui-v2.5.6/layui.js"></script>
		<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
		<style type="text/css">
			.icon{
				font-size: 20px;
			}
		</style>
	</head>
	<body>
		<div class="" style="margin-top: 3%;">
			<!-- 试卷信息 -->
			<div>
				<div align="center">
					<b style="font-size: 30px;" th:href="@{'info/' + ${paper.id}}" th:text="${paper.name}"></b>
					(<span th:text="${paper.createTime}"></span>)
					(<a th:href="@{'../info/' + ${paper.courseId}}" th:text="${paper.courseId}"></a>)
				</div>
		        <div class="layui-col-xs5 layui-col-xs-offset7" style="font-size: 20px;margin-top: 2%;">
		        	<span>-----试卷分数：</span>
		        	<span th:text="${paper.grade}"></span>/<span th:text="${paper.score}"></span>
		        </div>
			</div>
			<!-- 试卷详情 -->
			<div class="layui-collapse layui-col-xs10 layui-col-xs-offset1" style="margin-top: 3%;">
				<!-- 工具 -->
				<!--<div class="layui-colla-item">
					<div class="layui-colla-title">
						<span>快速导入</span>
					</div>
					<div class="layui-colla-content">
						<button type="button" class="layui-btn layui-btn-sm">DOC导入</button>
						<button type="button" class="layui-btn layui-btn-sm">PDF导入</button>
					</div>
				</div>-->
				<!-- 单项选择题 -->
				<div class="layui-colla-item">
					<div class="layui-colla-title">
						<span>单项选择题</span>
					</div>
					<div class="layui-colla-content layui-show">
						<button id="addOneChoice" type="button" class="layui-btn layui-btn-sm">
							<i class="layui-icon">&#xe608;</i> 添加
						</button>
						<div class="layui-col-md12" style="padding: 20px; background-color: #F2F2F2;margin-top: 1%;margin-bottom: 1%;">
							<div class="layui-row layui-col-space15">
								<div class="layui-col-md12 layui-card" th:each="oneChoice, status : ${paper.oneChoices}">
									<div class="layui-card-header">
										<button th:onclick="delect([[${oneChoice.id}]], 'oneChoice')" type="button" class="layui-btn layui-btn-sm">
											<i class="layui-icon">&#xe640;</i> 删除
										</button>
										<span th:text="${status.count} + '.&nbsp;'"></span>
										<span th:text="${oneChoice.question}"></span>
										(<span th:text="${oneChoice.score}"></span>分)
									</div>
									<div class="layui-card-body layui-row">
										<div class="layui-col-xs6">
											<div><span>A.&nbsp;</span><span th:text="${oneChoice.aa}"></span></div>
											<div><span>B.&nbsp;</span><span th:text="${oneChoice.ab}"></span></div>
											<div><span>C.&nbsp;</span><span th:text="${oneChoice.ac}"></span></div>
											<div><span>D.&nbsp;</span><span th:text="${oneChoice.ad}"></span></div>
											<div style="color: red;" >
												<span>正确答案：</span>
												<span th:text="${oneChoice.answer}"></span>
											</div>
										</div>
										<div class="layui-col-xs6">
											<div th:if="${oneChoice.isImage}"><img height="120px" width="120px" alt="图" th:src="@{'http://192.168.0.105/image/TestSystem/paper/oneChioce/' + ${oneChoice.id} + '.jpg'}"></div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- 多项选择题 -->
				<div class="layui-colla-item">
					<div class="layui-colla-title">
						<span>多项选择题</span>
					</div>
					<div class="layui-colla-content layui-show">
						<button id="addMultiple" type="button" class="layui-btn layui-btn-sm">
							<i class="layui-icon">&#xe608;</i> 添加
						</button>
						<div class="layui-col-md12" style="padding: 20px; background-color: #F2F2F2;margin-top: 1%;margin-bottom: 1%;">
							<div class="layui-row layui-col-space15">
								<div class="layui-col-md12 layui-card" th:each="multipleChoice, status : ${paper.multipleChoices}">
									<div class="layui-card-header">
										<button th:onclick="delect([[${multipleChoice.id}]], 'multipleChoice')" type="button" class="layui-btn layui-btn-sm">
											<i class="layui-icon">&#xe640;</i> 删除
										</button>
										<span th:text="${status.count} + '.&nbsp;'"></span>
										<span th:text="${multipleChoice.question}"></span>
										(<span th:text="${multipleChoice.score}"></span>分)
									</div>
									<div class="layui-card-body layui-row">
										<div class="layui-col-xs6">
											<div><span>A.&nbsp;</span><span th:text="${multipleChoice.aa}"></span></div>
											<div><span>B.&nbsp;</span><span th:text="${multipleChoice.ab}"></span></div>
											<div><span>C.&nbsp;</span><span th:text="${multipleChoice.ac}"></span></div>
											<div><span>D.&nbsp;</span><span th:text="${multipleChoice.ad}"></span></div>
											<div style="color: red;">
												<span>正确答案：</span>
												<span th:text="${multipleChoice.answer}"></span>
											</div>
										</div>
										<div class="layui-col-xs6">
											<div th:if="${multipleChoice.isImage}"><img height="120px" width="120px" alt="图" th:src="@{'http://192.168.0.105/image/TestSystem/paper/multipleChoice/' + ${multipleChoice.id} + '.jpg'}"></div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- 判断题 -->
				<div class="layui-colla-item">
					<div class="layui-colla-title">
						<span>判断题</span>
					</div>
					<div class="layui-colla-content layui-show">
						<button id="addJudgment" type="button" class="layui-btn layui-btn-sm">
							<i class="layui-icon">&#xe608;</i> 添加
						</button>
						<div class="layui-col-md12" style="padding: 20px; background-color: #F2F2F2;margin-top: 1%;margin-bottom: 1%;">
							<div class="layui-row layui-col-space15">
								<div class="layui-col-md12 layui-card" th:each="judgment, status : ${paper.judgments}">
									<div class="layui-card-header">
										<button th:onclick="delect([[${judgment.id}]], 'judgment')" type="button" class="layui-btn layui-btn-sm">
											<i class="layui-icon">&#xe640;</i> 删除
										</button>
										<span th:text="${status.count} + '.&nbsp;'"></span>
										<span th:text="${judgment.question}"></span>(&nbsp;&nbsp;)
										(<span th:text="${judgment.score}"></span>分)
									</div>
									<div class="layui-card-body">
										<div th:switch="${judgment.answer}">
											<span style="color: red;">正确答案：</span>
											<span th:case="true">正确</span>
											<span th:case="fasle">错误</span>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- 填空题 -->
				<div class="layui-colla-item">
					<div class="layui-colla-title">
						<span>填空题</span>
					</div>
					<div class="layui-colla-content layui-show">
						<button id="addFullInTheBlank" type="button" class="layui-btn layui-btn-sm">
							<i class="layui-icon">&#xe608;</i> 添加
						</button>
						<div class="layui-col-md12" style="padding: 20px; background-color: #F2F2F2;margin-top: 1%;margin-bottom: 1%;">
							<div class="layui-row layui-col-space15">
								<div class="layui-col-md12 layui-card" th:each="fullInTheBlank, status : ${paper.fullInTheBlanks}">
									<div class="layui-card-body">
										<div class="layui-col-xs12">
											<button th:onclick="delect([[${fullInTheBlank.id}]], 'fullInTheBlank')" type="button" class="layui-btn layui-btn-sm">
												<i class="layui-icon">&#xe640;</i> 删除
											</button>
											<span th:text="${status.count} + '.&nbsp;'"></span>
											<span th:text="${fullInTheBlank.question}"></span>
											(<span th:text="${fullInTheBlank.score}"></span>分)
										</div>
										<div class="layui-col-xs6">
											<span style="color: red;">正确答案：</span>
											<span th:text="${fullInTheBlank.answer}"></span>
										</div>
										<div class="layui-col-xs6">
											<div th:if="${fullInTheBlank.isImage}"><img height="120px" width="120px" alt="图" th:src="@{'http://192.168.0.105/image/TestSystem/paper/fullInTheBlank/' + ${fullInTheBlank.id} + '.jpg'}"></div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- 简答题 -->
				<div class="layui-colla-item">
					<div class="layui-colla-title">
						<span>简答题</span>
					</div>
					<div class="layui-colla-content layui-show">
						<button id="addDiscussion" type="button" class="layui-btn layui-btn-sm">
							<i class="layui-icon">&#xe608;</i> 添加
						</button>
						<div class="layui-col-md12" style="padding: 20px; background-color: #F2F2F2;margin-top: 1%;margin-bottom: 1%;">
							<div class="layui-row layui-col-space15">
								<div class="layui-col-md12 layui-card" th:each="discussion, status : ${paper.discussions}">
								<div class="layui-card-body" style="min-height: 100px;">
									<button th:onclick="delect([[${discussion.id}]], 'discussion')" type="button" class="layui-btn layui-btn-sm">
											<i class="layui-icon">&#xe640;</i> 删除
										</button>
									<span th:text="${status.count} + '.&nbsp;'"></span>
									<span th:text="${discussion.question}"></span>
									(<span th:text="${discussion.score}"></span>分)
									<div class="layui-col-xs6">
										答案
									</div>
									<div class="layui-col-xs6">
										<div th:if="${discussion.isImage}"><img height="120px" width="120px" alt="图" th:src="@{'http://192.168.0.105/image/TestSystem/paper/discussion/' + ${discussion.id} + '.jpg'}"></div>
									</div>
								</div>
							</div>
						</div>
					</div>
					</div>
				</div>
			</div>
		</div>
	</body>
	<div id="addOneDialog" style="display: none;">
		<form class="layui-form layui-col-xs11" style="margin-top: 20px;">
		  <div class="layui-form-item">
		    <label class="layui-form-label">题目</label>
		    <div class="layui-input-block">
		      <input type="text" id="oq" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">难容度</label>
		    <div class="layui-input-block">
			    <select id="od">
				    <option value="1">☆</option>
		     		<option value="2">☆☆</option>
		     		<option value="3">☆☆☆</option>
		     		<option value="4">☆☆☆☆</option>
		     		<option value="5">☆☆☆☆☆</option>
	     		</select>
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">题目分数</label>
		    <div class="layui-input-block">
		      <input type="text" id="os" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">是否有图片</label>
		    <div class="layui-input-block">
		      <input type="radio" name="oi" id="oi" value="0" class="layui-radio" title="没有" checked="checked">
		      <input type="radio" name="oi" id="oi" value="1" class="layui-radio" title="有">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">A</label>
		    <div class="layui-input-block">
		      <input type="text" id="oaa" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">B</label>
		    <div class="layui-input-block">
		      <input type="text" id="oab" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">C</label>
		    <div class="layui-input-block">
		      <input type="text" id="oac" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">D</label>
		    <div class="layui-input-block">
		      <input type="text" id="oad" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">正确选项</label>
		    <div class="layui-input-block">
			    <select id="oa">
				    <option value="A">A</option>
				    <option value="B">B</option>
				    <option value="C">C</option>
				    <option value="D">D</option>
	     		</select>
		    </div>
		  </div>
		</form>
	</div>
	<div id="addMultipleDialog" style="display: none;">
		<form class="layui-form layui-col-xs11" style="margin-top: 20px;">
		  <div class="layui-form-item">
		    <label class="layui-form-label">题目</label>
		    <div class="layui-input-block">
		      <input type="text" id="mq" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">难容度</label>
		    <div class="layui-input-block">
			    <select id="md">
				    <option value="1">☆</option>
		     		<option value="2">☆☆</option>
		     		<option value="3">☆☆☆</option>
		     		<option value="4">☆☆☆☆</option>
		     		<option value="5">☆☆☆☆☆</option>
	     		</select>
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">题目分数</label>
		    <div class="layui-input-block">
		      <input type="text" id="ms" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">是否有图片</label>
		    <div class="layui-input-block">
		      <input type="radio" name="mi" id="mi" value="0" class="layui-radio" title="没有" checked="checked">
		      <input type="radio" name="mi" id="mi" value="1" class="layui-radio" title="有">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">A</label>
		    <div class="layui-input-block">
		      <input type="text" id="maa" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">B</label>
		    <div class="layui-input-block">
		      <input type="text" id="mab" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">C</label>
		    <div class="layui-input-block">
		      <input type="text" id="mac" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">D</label>
		    <div class="layui-input-block">
		      <input type="text" id="mad" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">正确选项</label>
		    <div class="layui-input-block">
		    	<input type="checkbox" name="ma" value="A" title="A">
			    <input type="checkbox" name="ma" value="B" title="B">
			    <input type="checkbox" name="ma" value="C" title="C">
			    <input type="checkbox" name="ma" value="D" title="D">
		    </div>
		  </div>
		</form>
	</div>
	<div id="addJudgmentDialog" style="display: none;">
		<form class="layui-form layui-col-xs11" style="margin-top: 20px;">
		  <div class="layui-form-item">
		    <label class="layui-form-label">题目</label>
		    <div class="layui-input-block">
		      <input type="text" id="jq" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">难容度</label>
		    <div class="layui-input-block">
			    <select id="jd">
				    <option value="1">☆</option>
		     		<option value="2">☆☆</option>
		     		<option value="3">☆☆☆</option>
		     		<option value="4">☆☆☆☆</option>
		     		<option value="5">☆☆☆☆☆</option>
	     		</select>
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">题目分数</label>
		    <div class="layui-input-block">
		      <input type="text" id="js" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">正确答案</label>
		    <div class="layui-input-block">
		    	<input type="radio" name="ja" id="ja" value="1" class="layui-radio" title="正确">
		    	<input type="radio" name="ja" id="ja" value="0" class="layui-radio" title="错误">
		    </div>
		  </div>
		</form>
	</div>
	<div id="addFullInTheBlankDialog" style="display: none;">
		<form class="layui-form layui-col-xs11" style="margin-top: 20px;">
		  <div class="layui-form-item">
		    <label class="layui-form-label">题目</label>
		    <div class="layui-input-block">
		      <input type="text" id="fq" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">难容度</label>
		    <div class="layui-input-block">
			    <select id="fd">
				    <option value="1">☆</option>
		     		<option value="2">☆☆</option>
		     		<option value="3">☆☆☆</option>
		     		<option value="4">☆☆☆☆</option>
		     		<option value="5">☆☆☆☆☆</option>
	     		</select>
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">题目分数</label>
		    <div class="layui-input-block">
		      <input type="text" id="fs" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">是否有图片</label>
		    <div class="layui-input-block">
		      <input type="radio" name="fi" id="fi" value="0" class="layui-radio" title="没有" checked="checked">
		      <input type="radio" name="fi" id="fi" value="1" class="layui-radio" title="有">
		    </div>
		  </div>
		 
		  <div class="layui-form-item">
		    <label class="layui-form-label">正确答案</label>
		    <div class="layui-input-block">
		    	<input type="text" class="layui-input" id="fa">
		    </div>
		  </div>
		</form>
	</div>
	<div id="addDiscussionDialog" style="display: none;">
		<form class="layui-form layui-col-xs11" style="margin-top: 20px;">
		  <div class="layui-form-item">
		    <label class="layui-form-label">题目</label>
		    <div class="layui-input-block">
		       <textarea name="dq" id="dq" placeholder="请输入题目" class="layui-textarea"></textarea>
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">难容度</label>
		    <div class="layui-input-block">
			    <select id="dd">
				    <option value="1">☆</option>
		     		<option value="2">☆☆</option>
		     		<option value="3">☆☆☆</option>
		     		<option value="4">☆☆☆☆</option>
		     		<option value="5">☆☆☆☆☆</option>
	     		</select>
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">题目分数</label>
		    <div class="layui-input-block">
		      <input type="text" id="ds" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">是否有图片</label>
		    <div class="layui-input-block">
		      <input type="radio" name="di" id="di" value="0" class="layui-radio" title="没有" checked="checked">
		      <input type="radio" name="di" id="di" value="1" class="layui-radio" title="有">
		    </div>
		  </div>
		</form>
	</div>
	<script type="text/javascript">
		var url = window.location.search.substring(1);
		var ids = url.split("=");
		var paperId = ids[1];
		function delect(id, type){
			layui.use('layer', function(){
				var layer = layui.layer;
				layer.confirm('确定删除?', {
					icon: 0, 
					title:'提示',
					offset: 't'
				}, function(index){
					var load = layer.load(1);
					$.post('delete', {
						type: type,
						id: id
					}, function(res){
						layer.close(load);
						if(res.code == '00000'){
							layer.msg('删除成功', {icon: 1});
							location.reload();
						}else{
							layer.msg(res.message, {icon: 2}); 
						}
					}, 'json');
					layer.close(index);
				});
			});
		}
		layui.use(['element', 'layer', 'form'], function(){
			var element = layui.element;
			var layer = layui.layer;
			var form = layui.form;
			$("#addOneChoice").on("click", function(){
				layer.open({
					type: 1,
					title: '新增单项选择题',
					shadeClose: true,
					shade: false,
					offset: 't',
					btn: ['新增'],
					yes: function(index){
						var question = $("#oq").val();
						var degree = $("#od").val();
						var score = $("#os").val();
						var isImage = $("#oi").val();
						var aa = $("#oaa").val();
						var ab = $("#oab").val();
						var ac = $("#oac").val();
						var ad = $("#oad").val();
						var answer = $("#oa").val();
						$.post('addOneChoice', {
							question: question,
							degree: degree,
							score: score,
							paperId: paperId,
							isImage: isImage,
							aa: aa,
							ab: ab,
							ac: ac,
							ad: ad,
							answer: answer
						}, function(res){
							if(res.code == '00000'){
								location.reload()
							}else{
								layer.msg("添加失败", {icon:0});
							}
						}, 'json');
						layer.close(index);
					},
					maxmin: true, //开启最大化最小化按钮
					area: ['600px', '450px'],
					content: $("#addOneDialog")
				});
			})
			$("#addMultiple").on("click", function(){
				layer.open({
					type: 1,
					title: '新增多项选择题',
					shadeClose: true,
					shade: false,
					offset: 't',
					btn: ['新增'],
					yes: function(index){
						var question = $("#mq").val();
						var degree = $("#md").val();
						var score = $("#ms").val();
						var isImage = $("#mi").val();
						var aa = $("#maa").val();
						var ab = $("#mab").val();
						var ac = $("#mac").val();
						var ad = $("#mad").val();
						var answer = []; 
					    $('input[name="ma"]:checked').each(function(){ 
					    	answer.push($(this).val())
					    }); 
					    answer = answer.join(',');
					    $.post('addMultipleChoice', {
							question: question,
							degree: degree,
							score: score,
							paperId: paperId,
							isImage: isImage,
							aa: aa,
							ab: ab,
							ac: ac,
							ad: ad,
							answer: answer
						}, function(res){
							if(res.code == '00000'){
								location.reload()
							}else{
								layer.msg("添加失败", {icon:0});
							}
						}, 'json');
						layer.close(index);
					},
					maxmin: true, //开启最大化最小化按钮
					area: ['600px', '450px'],
					content: $("#addMultipleDialog")
				});
			})
			$("#addJudgment").on('click', function(){
				layer.open({
					type: 1,
					title: '新增判断题',
					shadeClose: true,
					shade: false,
					offset: 't',
					btn: ['新增'],
					yes: function(index){
						var question = $("#jq").val();
						var degree = $("#jd").val();
						var score = $("#js").val();
						var isImage = $("#ji").val();
						var answer = $("#ja").val();
						$.post('addJudgment', {
							question: question,
							degree: degree,
							score: score,
							paperId: paperId,
							answer: answer
						}, function(res){
							if(res.code == '00000'){
								location.reload()
							}else{
								layer.msg("添加失败", {icon:0});
							}
						}, 'json');
						layer.close(index);
					},
					maxmin: true, //开启最大化最小化按钮
					area: ['600px', '450px'],
					content: $("#addJudgmentDialog")
				});
			})
			$("#addFullInTheBlank").on('click', function(){
				layer.open({
					type: 1,
					title: '新增填空题',
					shadeClose: true,
					shade: false,
					offset: 't',
					btn: ['新增'],
					yes: function(index){
						var question = $("#fq").val();
						var degree = $("#fd").val();
						var score = $("#fs").val();
						var isImage = $("#fi").val();
						var answer = $("#fa").val();
						$.post('addFullInTheBlank', {
							question: question,
							degree: degree,
							score: score,
							paperId: paperId,
							isImage: isImage,
							answer: answer
						}, function(res){
							if(res.code == '00000'){
								location.reload()
							}else{
								layer.msg("添加失败", {icon:0});
							}
						}, 'json');
						layer.close(index);
					},
					maxmin: true, //开启最大化最小化按钮
					area: ['600px', '450px'],
					content: $("#addFullInTheBlankDialog")
				});
			})
			$("#addDiscussion").on('click', function(){
				layer.open({
					type: 1,
					title: '新增简答题',
					shadeClose: true,
					shade: false,
					offset: 't',
					btn: ['新增'],
					yes: function(index){
						var question = $("#dq").val();
						var degree = $("#dd").val();
						var score = $("#ds").val();
						var isImage = $("#di").val();
						$.post('addDiscussion', {
							question: question,
							degree: degree,
							score: score,
							paperId: paperId,
							isImage: isImage,
						}, function(res){
							if(res.code == '00000'){
								location.reload()
							}else{
								layer.msg("添加失败", {icon:0});
							}
						}, 'json');
						layer.close(index);
					},
					maxmin: true, //开启最大化最小化按钮
					area: ['600px', '450px'],
					content: $("#addDiscussionDialog")
				});
			})
		});
	</script>
</html>